How to use the array[index] method In Javascript
Accessing JSON array values using the numerical indexes. we can directly access the JSON array by accessing their indexes.
Example: Accessing values using the numerical index.
Javascript
let jsonArrayData = [ { "ComapnyName" : "w3wiki" , "Location" : "Noida" }, { "Courses" : "DSA self paced course" } ]; console.log(jsonArrayData[0]); // Accessing first element console.log(jsonArrayData[1]); // Accessing second element |
Output
{ ComapnyName: 'w3wiki', Location: 'Noida' } { Courses: 'DSA self paced course' }
How to Get a Value from a JSON Array in JavaScript ?
We are going to iterate or access the value of a JSON array in JavaScript. There are several ways and techniques to access values from the JSON Array which are explained in detail below and are further divided into several possible techniques.
Table of Content
- Using the array[index] method
- Using the array[key] method
- Using the array.slice method
- Using for…of the loop
- Using forEach()
- Using the map() method
- Using filter() method
- Using the find() method
- Using findIndex() method
- Using some() method
- Using recursive traversal of JSON array
- Using the custom reduce method
- Using custom classes